(function (vc) {
    vc.extends({
        propTypes: {
            callBackListener: vc.propTypes.string, //父组件名称
            callBackFunction: vc.propTypes.string //父组件监听方法
        },
        data: {
            allocationOrderAuditInfo: {
                state: '',
                remark: ''
            }
        },
        watch: {
            "allocationOrderAuditInfo.state": {//深度监听，可监听到对象、数组的变化
                handler(val, oldVal) {
                    if (vc.notNull(val) && $that.allocationOrderAuditInfo.state == '2002') {
                        $that.allocationOrderAuditInfo.remark = "同意";
                    } else {
                        $that.allocationOrderAuditInfo.remark = "";
                    }
                },
                deep: true
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('allocationOrderAudit', 'openAllocationOrderAuditModal', function () {
                $('#allocationOrderAuditModel').modal('show');
            });
        },
        methods: {
            allocationOrderAuditValidate() {
                return vc.validate.validate({
                    allocationOrderAuditInfo: $that.allocationOrderAuditInfo
                }, {
                    'allocationOrderAuditInfo.state': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "审核状态不能为空"
                        },
                        {
                            limit: "num",
                            param: "",
                            errInfo: "审核状态错误"
                        },
                    ],
                    'allocationOrderAuditInfo.remark': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "原因内容不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "200",
                            errInfo: "原因内容不能超过200"
                        },
                    ]
                });
            },
            _auditSubmit: function () {
                if (!$that.allocationOrderAuditValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
                //不提交数据将数据 回调给侦听处理
                if (vc.notNull($props.callBackListener)) {
                    vc.emit($props.callBackListener, $props.callBackFunction, $that.allocationOrderAuditInfo);
                    $('#allocationOrderAuditModel').modal('hide');
                    $that.clearAddBasePrivilegeInfo();
                    return;
                }
            },
            clearAddBasePrivilegeInfo: function () {
                $that.allocationOrderAuditInfo = {
                    state: '',
                    remark: ''
                }
            }
        }
    });
})(window.vc);
